<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Rtgm\smecc\SM3;

class GeneralDigest
{
    private $xBuf = [];
    private $xBufOff;
    private $byteCount;
    const BYTE_LENGTH = 64;
    public function setGeneralDigest($t)
    {
        $this->arraycopy($t->xBuf, 0, $this->xBuf, 0, sizeof($t->xBuf));
        $this->xBufOff = $t->xBufOff;
        $this->byteCount = $t->byteCount;
    }
    public function __construct()
    {
        $this->xBuf[0] = 0;
        $this->xBuf[1] = 0;
        $this->xBuf[2] = 0;
        $this->xBuf[3] = 0;
    }
    public function Update($input)
    {
        $this->xBuf[$this->xBufOff++] = $input;
        if($this->xBufOff == sizeof($this->xBuf)) {
            $this->ProcessWord($this->xBuf, 0);
            $this->xBufOff = 0;
        }
        $this->byteCount++;
    }
    public function BlockUpdate($input, $inOff, $length)
    {
        while ($this->xBufOff != 0 && 0 < $length) {
            $this->Update($input[$inOff]);
            $inOff++;
            $length--;
        }
        while (sizeof($this->xBuf) < $length) {
            $this->ProcessWord($input, $inOff);
            $inOff += sizeof($this->xBuf);
            $length -= sizeof($this->xBuf);
            $this->byteCount += sizeof($this->xBuf);
        }
        while (0 < $length) {
            $this->Update($input[$inOff]);
            $inOff++;
            $length--;
        }
    }
    public function Finish()
    {
        $bitLength = $this->LeftRotateLong($this->byteCount, 3);
        $this->Update(128);
        while ($this->xBufOff != 0) {
            $this->Update(0);
        }
        $this->ProcessLength($bitLength);
        $this->ProcessBlock();
    }
    public function Reset()
    {
        $this->byteCount = 0;
        $this->xBufOff = 0;
        $this->xBuf[0] = 0;
        $this->xBuf[1] = 0;
        $this->xBuf[2] = 0;
        $this->xBuf[3] = 0;
    }
    public function GetByteLength() : int
    {
        return $this::BYTE_LENGTH;
    }
}

?>